package de.pyranja.storage;

import com.google.common.util.concurrent.ListenableFuture;

/**
 * Describes binary data that is stored in the storage. Includes a reference to
 * the execution result of storing the blob.
 * @author Chris Borckholder
 */
public class Blob {
	/*
	 * A struct-like wrapper for the descriptor of a blob. Holds a storage wide
	 * unique identifier and its size.
	 * Additionally the outcome of storing the blob is captured.
	 */
	private final String id;
	private final long size;
	
	private ListenableFuture<String> async;
	
	public Blob(final String id, final long size) {
		super();
		this.id = id;
		this.size = size;
	}
	
	/**
	 * @return the unique identifier of the data
	 */
	public String getId() {
		return id;
	}
	/**
	 * @return the size in bytes of the data
	 */
	public long getSize() {
		return size;
	}

	/**
	 * @return the asynchronous result of storing the blob
	 */
	public ListenableFuture<String> async() {
		return async;
	}

	/**
	 * @param async future of storing result
	 */
	void setAsync(ListenableFuture<String> async) {
		this.async = async;
	}
}